package com.lgy.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object emp = request.getSession().getAttribute("emp");
        if(emp!=null||request.getServletPath().contains("login")||request.getServletPath().contains("register")){
            return true;
        }

        response.sendRedirect(request.getContextPath()+"/jsp/login.jsp");
        return false;
    }
}
